function newElement () {
  $.ajax({
    url: 'newElement.html',
    success: function (data) {
      $('#newElementContent').html (data);
      $('#newElementText').tinymce({
		language : 'nb',
		// Location of TinyMCE script
		script_url : 'includes/tinymce/jscripts/tiny_mce/tiny_mce_gzip.php',
		// General options
		theme : "advanced",
		skin: "bootstrap",
		plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,advlist,spellchecker",

		// Theme options
		theme_advanced_buttons1 : "spellchecker,iespell,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect,|,forecolor,backcolor",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,removeformat,help,code,|,visualchars,nonbreaking,visualaid,|,insertdate,inserttime",
		theme_advanced_buttons3 : "tablecontrols,|,sub,sup,|,charmap,emotions,media,advhr,|,print,|,fullscreen,|,cite,abbr,acronym,del,ins",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
 
		spellchecker_languages : "Norwegian=no,+English=en",
		file_browser_callback : 'fileBrowser',
		
		height : 400,
		width : 859,
		relative_urls: true,
  		extended_valid_elements : "iframe[src|frameborder|style|scrolling|class|width|height|name|align]"
	  });
	}
  });
  $('#newElement').modal({show: true });  // Display the New Element dialog
}

function storeNewElement() {
  $.ajax({
	url: 'includes/functions/storeNewElement.php',
	data: {title: $('#content form input')[0].value, 
	content: $('#newElement').html()},
	type: 'post',
	success: function (tmp) {
	  data = eval ('('+tmp+')');
	  if (data.ok) {
	    alert (data.message);
		$('#content').load ('myElements.php');
	  } else
	    alert (data.message);
	}
  });
}

function test() {
	$('#content').load ('myElements.php');
}